package Leetcode;

public class Leetcode_305 {
    public static String getSmallestString(int n, int k) {
        StringBuilder ans = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            int lower = Math.max(1, k - (n - i) * 26);
            k -= lower;
            ans.append((char) ('a' + lower - 1));
        }
        return ans.toString();
    }

    public static void main(String[] args) {
        int n = 3, k = 27;
        System.out.println(getSmallestString(n,k));
    }
}
